{% extends 'base.html' %}
{% load static cmstags %}

{% block css %}
    <link rel="stylesheet" href="{% static 'css/article.css' %}"/>
{% endblock %}
{% block js %}

{% endblock %}

{% block seo %}
    <title>{{ article.title }}- {{ settings.site_name }}</title>
    {% if article.tags.all %}
        <meta name="keywords" content="{{ article.tags.all|join:"," }}"/>
    {% else %}
        <meta name="keywords" content="{{ article.title }}"/>
    {% endif %}
    <meta name="description" content="{{ article.summary }}"/>
    <meta property="og:title" content="{{ article.title }}">
    <meta property="og:og:description" content="{{ article.summary }}">
    <meta property="og:type" content="article">
    <meta property="og:site_name" content="{{ settings.site_name }}">
    <meta property="og:url" content="{% get_current_url %}">
    <meta property="og:image" content="{% get_current_host %}{{ article.cover }}">

{% endblock %}
{% block main %}
    <div class="breadcrumbs-wrap">
        <ul class="breadcrumbs">
            <li><a href="/">首页</a></li>
            <li><a href="{% url 'category' article.category.alias %}">{{ article.category.name }}</a></li>
            <li class="active">正文</li>
        </ul>
    </div>
    <div class="article">
        <h1 class="title">{{ article.title }}</h1>
        <div class="info">
            <span class="iconfont icon-book"></span>
            <span><a href="{% url 'category' article.category.alias %}" target="_blank">{{ article.category.name }}</a></span>

            <span class="iconfont icon-date"></span>
            <span>{{ article.create_date }}</span>

            <span class="iconfont icon-yanjing"></span>
            <span>{{ article.hits }}</span>
        </div>

        <div class="content">
            {{ article.content|safe }}

            <div class="tags clearfix">
                {% for item in article.tags.all %}
                    <a href="{% url 'tag' item.name %}">{{ item }}</a>
                {% endfor %}
            </div>
        </div>
        <div class="prev-next">
            {% get_prev article.id as prev %}
            {% if prev %}
                <div class="item">
                    <span>上一篇：</span>
                    <a href="{% url 'article' prev.category__alias prev.id %}">{{ prev.title }}</a>
                </div>
            {% endif %}

            {% get_next article.id as next %}
            {% if next %}
                <div class="item">
                    <span>下一篇：</span>
                    <a href="{% url 'article' next.category__alias next.id %}">{{ next.title }}</a>
                </div>
            {% endif %}
        </div>
    </div>
{% endblock %}

{% block side %}
    <div class="item">
        <div class="head-title">热门标签</div>
        <div class="side-article">
            <div class="tags hot-tags clearfix">
                {% get_tag_random 20 as tags %}
                {% for t in tags %}
                    <a href="{% url 'tag' t.name %}">{{ t.name }}</a>
                {% endfor %}
            </div>
        </div>
    </div>
    {{ block.super }}
{% endblock %}